From: kaf24@firebug.cl.cam.ac.uk Date: Thu, 27 Apr 2006 14:55:09 +0000 (+0100) Subject: Add BUILD_BUG_ON() and a handful of users. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16108^2~66 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=dc38d274fe183d858c5915f7764241f58422fbe0;p=xen.git Add BUILD_BUG_ON() and a handful of users. Signed-off-by: Jan Beulich --- diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 494c13b6d1..944bdb2e00 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -391,17 +391,17 @@ void __init __start_xen(multiboot_info_t *mbi) total_pages = nr_pages; /* Sanity check for unwanted bloat of dom0_op structure. */ - BUG_ON(sizeof(((struct dom0_op *)0)->u) != - sizeof(((struct dom0_op *)0)->u.pad)); + BUILD_BUG_ON(sizeof(((struct dom0_op *)0)->u) != + sizeof(((struct dom0_op *)0)->u.pad)); - BUG_ON(sizeof(start_info_t) > PAGE_SIZE); - BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); - BUG_ON(sizeof(vcpu_info_t) != 64); + BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(vcpu_info_t) != 64); /* __foo are defined in public headers. Check they match internal defs. */ - BUG_ON(__HYPERVISOR_VIRT_START != HYPERVISOR_VIRT_START); + BUILD_BUG_ON(__HYPERVISOR_VIRT_START != HYPERVISOR_VIRT_START); #ifdef HYPERVISOR_VIRT_END - BUG_ON(__HYPERVISOR_VIRT_END != HYPERVISOR_VIRT_END); + BUILD_BUG_ON(__HYPERVISOR_VIRT_END != HYPERVISOR_VIRT_END); #endif init_frametable(); diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 8b9253b020..124d49ade5 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -16,6 +16,9 @@ #define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 ) +/* Force a compilation error if condition is true */ +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) + #ifndef NDEBUG #define ASSERT(_p) { if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s\n", #_p , __LINE__, __FILE__); BUG(); } } #else